package com.zixuan.gulicollege.eduservice.controller.front;

import com.zixuan.gulicollege.common_utils.R;
import com.zixuan.gulicollege.eduservice.service.EduCourseService;
import com.zixuan.gulicollege.eduservice.service.EduTeacherService;
import com.zixuan.gulicollege.entity.eduservice.EduCourse;
import com.zixuan.gulicollege.entity.eduservice.EduTeacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: FrontController
 * @Author: zixuan
 * @Date: 2021/5/16 20:53
 * @Description:
 */

@RestController
@RequestMapping("/edu_service/front")
public class FrontController {

    @Autowired
    private EduCourseService courseService;

    @Autowired
    private EduTeacherService teacherService;

    /**
     * 初始化首页数据
     * @return
     */
    @GetMapping("/getInitFront")
    public R getCourseFront(){

        // 查询前8个课程
        List<EduCourse> courseList = courseService.getCourseList();

        // 查询前4个讲师
        List<EduTeacher> teacherList = teacherService.getTeacherList();

        return R.ok().data("courseList", courseList).data("teacherList", teacherList);
    }

}
